package com.fudian.spark_platform.Transform

import com.fudian.spark_platform.Configure.TransformConfig
import org.apache.spark.ml.feature.StringIndexer
import org.apache.spark.sql.DataFrame

/**
  * CopyRight FuMan AI DataDimming.co SHANGHAI,RPC
  * File can't be used to License
  * Created by XiaoJun on 2018/3/13.
  */
class StringIndex {

    var df: DataFrame = null
    var config: TransformConfig = null


    def this(df:DataFrame,config:TransformConfig) = {
        this()
        this.df = df
        this.config = config
    }

    def do_transform(): DataFrame = {

        val inputCol = this.config.transformConfig("inputCol").toString
        val outputCol = this.config.transformConfig("outputCol").toString

        val transform = new StringIndexer()
            .setInputCol(inputCol)
            .setOutputCol(outputCol)
            .fit(this.df)
        transform.transform(this.df)
    }
}
